<?php

use Illuminate\Database\Seeder;
use WoXuanWang\User\Models\User;
use WoXuanWang\Company\Models\Company;
use WoXuanWang\Customer\Models\Customer;
use WoXuanWang\DataHistory\Models\DataHistory;
use WoXuanWang\DeviceType\Models\DeviceType;
use WoXuanWang\MonitorMethod\Models\MonitorMethod;
use WoXuanWang\Point\Models\Point;
use WoXuanWang\Device\Models\Device;
use WoXuanWang\Solution\Models\Solution;
use WoXuanWang\Project\Models\Project;
use WoXuanWang\Organization\Models\Organization;
use WoXuanWang\Supervisor\Models\Supervisor;
use WoXuanWang\DataType\Models\DataType;

class TestDataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $device = Device::where('name', '测缝计TEST')->first();
        if (!$device) {
            return false;
        }
        $point = Point::where('device_id', $device->id)->first();

        $data_history = factory(DataHistory::class, 100)->create()->each(function ($data) use ($point, $device) {
            $data->point_id = $point->id;
            $data->device_id = $device->id;
            $data->device_type_id = $device->device_type_id;
            $data->save();
        });
    }
}
